import { Component, EventEmitter, Input, Output } from '@angular/core';
import { SearchDropdownMenuItem } from './../search-dropdown-menu-item';

@Component({
  selector: 'j:lbuttons',
  templateUrl: './list-form-buttons.component.html',
  styleUrls: ['./list-form-buttons.component.less'],
})
export class ListFormButtonsComponent {
  @Input() searchText: string = '';
  @Output() searchTextChange = new EventEmitter<string>();

  get code(): string {
    return this.searchText;
  }

  set code(value: string) {
    this.searchText = value;
    this.searchTextChange.emit(value);
  }

  //按钮是否显示
  @Input()
  newBtnVisible: boolean = true;
  @Input()
  deleteBtnVisible: boolean = true;
  @Input()
  operateDividerVisible: boolean = true;
  @Input()
  submitBtnVisible: boolean = true;
  @Input()
  backBtnVisible: boolean = true;
  @Input()
  approveBtnVisible: boolean = true;
  @Input()
  unapproveBtnVisible: boolean = true;
  @Input()
  approveDividerVisible: boolean = true;
  @Input()
  exportBtnVisible: boolean = true;
  @Input()
  printBtnVisible: boolean = true;
  @Input()
  exportDividerVisible: boolean = true;
  @Input()
  refreshBtnVisible: boolean = true;
  @Input()
  searchDetailBtnVisible: boolean = true;

  @Input()
  searchPlaceholder: string = '';

  @Input()
  newBtnDisabledFn: () => boolean = () => false;
  @Input()
  deleteBtnDisabledFn: () => boolean = () => false;
  @Input()
  operateDividerDisabledFn: () => boolean = () => false;
  @Input()
  submitBtnDisabledFn: () => boolean = () => false;
  @Input()
  backBtnDisabledFn: () => boolean = () => false;
  @Input()
  approveBtnDisabledFn: () => boolean = () => false;
  @Input()
  unapproveBtnDisabledFn: () => boolean = () => false;
  @Input()
  approveDividerDisabledFn: () => boolean = () => false;
  @Input()
  exportBtnDisabledFn: () => boolean = () => false;
  @Input()
  printBtnDisabledFn: () => boolean = () => false;
  @Input()
  exportDividerDisabledFn: () => boolean = () => false;
  @Input()
  refreshBtnDisabledFn: () => boolean = () => false;
  @Input()
  searchDropdownMenuItems: SearchDropdownMenuItem[] = [];

  get newBtnDisabled() {
    return this.newBtnDisabledFn();
  }
  get deleteBtnDisabled() {
    return this.deleteBtnDisabledFn();
  }
  get operateDividerDisabled() {
    return this.operateDividerDisabledFn();
  }
  get submitBtnDisabled() {
    return this.submitBtnDisabledFn();
  }
  get backBtnDisabled() {
    return this.backBtnDisabledFn();
  }
  get approveBtnDisabled() {
    return this.approveBtnDisabledFn();
  }
  get unapproveBtnDisabled() {
    return this.unapproveBtnDisabledFn();
  }
  get approveDividerDisabled() {
    return this.approveDividerDisabledFn();
  }
  get exportBtnDisabled() {
    return this.exportBtnDisabledFn();
  }
  get printBtnDisabled() {
    return this.printBtnDisabledFn();
  }
  get exportDividerDisabled() {
    return this.exportDividerDisabledFn();
  }
  get refreshBtnDisabled() {
    return this.refreshBtnDisabledFn();
  }

  @Output() readonly newBtnClick = new EventEmitter();
  @Output() readonly deleteBtnClick = new EventEmitter();
  @Output() readonly operateDividerClick = new EventEmitter();
  @Output() readonly submitBtnClick = new EventEmitter();
  @Output() readonly backBtnClick = new EventEmitter();
  @Output() readonly approveBtnClick = new EventEmitter();
  @Output() readonly unapproveBtnClick = new EventEmitter();
  @Output() readonly approveDividerClick = new EventEmitter();
  @Output() readonly exportBtnClick = new EventEmitter();
  @Output() readonly printBtnClick = new EventEmitter();
  @Output() readonly exportDividerClick = new EventEmitter();
  @Output() readonly refreshBtnClick = new EventEmitter();

  @Output() readonly searchBtnClick = new EventEmitter();
  @Output() readonly searchDetailBtnClick = new EventEmitter();

  OnNewBtnClick() {
    this.newBtnClick.emit();
  }
  OnDeleteBtnClick() {
    this.deleteBtnClick.emit();
  }
  OnOperateDividerClick() {
    this.operateDividerClick.emit();
  }
  OnSubmitBtnClick() {
    this.submitBtnClick.emit();
  }
  OnBackBtnClick() {
    this.backBtnClick.emit();
  }
  OnApproveBtnClick() {
    this.approveBtnClick.emit();
  }
  OnUnapproveBtnClick() {
    this.unapproveBtnClick.emit();
  }
  OnApproveDividerClick() {
    this.approveDividerClick.emit();
  }
  OnExportBtnClick() {
    this.exportBtnClick.emit();
  }
  OnPrintBtnClick() {
    this.printBtnClick.emit();
  }
  OnExportDividerClick() {
    this.exportDividerClick.emit();
  }
  OnRefreshBtnClick() {
    this.refreshBtnClick.emit();
  }

  OnSearchBtnClick() {
    this.searchBtnClick.emit(this.searchText);
  }

  OnSearchDetailBtnClick() {
    this.searchDetailBtnClick.emit();
  }
}
